package string;

import java.io.StringReader;

/**
 * 字符串支持正表达式的三种方法：替换
 * String replaceAll(String regex,String str)
 * 将当前字符串中满足正则表达式的部分替换为给定的字符串
 *
 */
public class ReplaceAllDemo {
    public static void main(String[] args) {
        String line="asdsd123ddas456dad";
        line=line.replaceAll("[0-9]+","NUMBER");
        System.out.println(line);


        String line1="asdsd123ddas456dad";
        line1=line1.replaceAll("[a-zA-Z]+","NUMBER");
        System.out.println(line1);

        String regex="(wangbadan|dsb)";
        String message="你个wangbadan，你个dsb";
        message=message.replaceAll(regex,"***");
        System.out.println(message);
    }
}
